package classes;

import javax.swing.*;
import javax.swing.table.TableRowSorter;
import java.sql.SQLException;

public class SelectTable extends JTable {
    public SelectTable(String sql) {
        try {
            ResultSetTableModel tableModel = new ResultSetTableModel(Consts.DATABASE_URL,
                    Consts.USERNAME, Consts.PASSWORD, sql);
            setModel(tableModel);
            final TableRowSorter<ResultSetTableModel> sorter = new TableRowSorter<>(tableModel);
            setRowSorter(sorter);
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}
